﻿namespace lie2
{
    internal class by1
    {
        static void Main(string[] args)
        {
            //作业：会移动的Miku，完成！ヾ(≧▽≦*)o
            Console.OutputEncoding = System.Text.Encoding.UTF8;
            Console.BackgroundColor = ConsoleColor.Yellow;
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.CursorVisible = false;
            int x = 0, y = 0;//变量要在循环外定义，不然进入循环会一直重置（怪不得我老动不了）
            while (true)
            {
                Console.SetCursorPosition(x, y);
                Console.Write(" Miku");
                char a = Console.ReadKey(true).KeyChar;
                Console.SetCursorPosition(x,y);
                Console.Write("         ");
                switch(a)
                {
                    case 'w':
                    case 'W':
                        y-=1; 
                        if (y<0)
                        {
                            y = 0;
                        }
                        break;
                    case 's':
                    case 'S':
                        y += 1;
                        if(y>Console.BufferHeight-1 )
                        {
                            y = Console.BufferHeight-1;
                        }
                        break;
                    case 'a':
                    case 'A':
                        x-=2; 
                        if (x<0)
                        {
                            x = 0;
                        }
                        break;
                    case 'd':
                    case 'D':
                        x+=2;
                        if(x>Console.BufferWidth-1)
                        {
                            x = Console.BufferWidth-1;
                        }
                        break;
                }
            }
        }
    }
}
